<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
  <table border="1px">
    <tr>
      <th>商品名称</th>
      <th>价格</th>
      <th>库存</th>
    </tr>
  </table>
   <script>
     let productArr = [
     {title:'华为手机',price:5000,stock:100},
     {title:'华为手机1',price:50001,stock:1001},
     {title:'华为手机2',price:50002,stock:1002},
     {title:'华为手机3',price:50003,stock:1003}
     ]
     let table = document.querySelector("table");
     for (let i = 0 ; i < productArr.length ; i++)
     {
        let nameTd =  document.createElement('td');
        let priceTd = document.createElement('td');
        let stockTd = document.createElement('td');
        let tr = document.createElement("tr");
        nameTd.innerHTML = productArr[i].title;
        priceTd.innerHTML = productArr[i].price;
        stockTd.innerHTML = productArr[i].stock;
        tr.append(nameTd,priceTd,stockTd);
        table.append(tr);

     }


   </script>







</body>
</html>